import 'package:flutter/material.dart';

class BannerWidget extends StatefulWidget {
  @override
  _BannerWidgetState createState() => _BannerWidgetState();
}

class _BannerWidgetState extends State<BannerWidget> {
  bool _isfavor = false;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Image.asset(
          "assets/image/lyt.jpg",
          width: double.infinity,
        ),
        Positioned(
            bottom: 0,
            //注意，这里左右必须指定，否则报错
            left: 0,
            right: 0,
            child: Container(
              color: Color.fromARGB(100, 0, 0, 0),
              padding: EdgeInsets.symmetric(horizontal: 8),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    "广告的标题",
                    style: TextStyle(color: Colors.white),
                  ),
                  IconButton(
                    icon: Icon(
                      Icons.favorite,
                      color: _isfavor ? Colors.red : Colors.white,
                    ),
                    onPressed: () {
                      setState(() {
                        _isfavor = !_isfavor;
                      });
                    },
                  )
                ],
              ),
            ))
      ],
    );
  }
}
